//package com.pubinfo.passbook.shiro.filter;
//
//import org.springframework.http.HttpMethod;
//import org.springframework.http.HttpStatus;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.Enumeration;
//
///*
//配置跨越访问
// */
//@Component
//public class AllowOriginFilter implements Filter {
//
//  @SuppressWarnings("unused")
//  public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
//    HttpServletResponse response = (HttpServletResponse) res;
//    HttpServletRequest request = (HttpServletRequest) req;
//    String token = request.getHeader("token");
//    Enumeration<String> eu = request.getHeaderNames();
//    response.setHeader("Access-Control-Allow-Origin", "*"); // 设置允许所有跨域访问
//    response.setHeader("Access-Control-Allow-Methods", "POST,GET,PUT,OPTIONS,DELETE");
//    response.setHeader("Access-Control-Max-Age", "3600");
//    response.setHeader("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept,Authorization,token");
//    response.setHeader("Access-Control-Allow-Credentials", "true");
//
//    String method = request.getMethod();
//    if (HttpMethod.OPTIONS.toString().equals(method)) {
//      response.setStatus(HttpStatus.NO_CONTENT.value());
//    }
//    chain.doFilter(req, res);
//  }
//
//  public void init(FilterConfig filterConfig) {
//  }
//
//  public void destroy() {
//  }
//
//}